package com.sina.microblog.ut.utils
{
	import com.sina.microblog.data.MicroBlogComment;
	import com.sina.microblog.data.MicroBlogCount;
	import com.sina.microblog.data.MicroBlogDirectMessage;
	import com.sina.microblog.data.MicroBlogRateLimit;
	import com.sina.microblog.data.MicroBlogRelationshipDescriptor;
	import com.sina.microblog.data.MicroBlogStatus;
	import com.sina.microblog.data.MicroBlogUser;
	import com.sina.microblog.data.MicroBlogUsersRelationship;
	import com.sina.microblog.events.MicroBlogErrorEvent;
	import com.sina.microblog.events.MicroBlogEvent;
	
	import flexunit.framework.Assert;

	public class AssertResult
	{
		public static function assertError(event:MicroBlogErrorEvent, params:Object=null):void
		{
			Assert.assertTrue(true);
		}
		
		public static function assertCommentArray(event:MicroBlogEvent, params:Object=null):void
		{
			var cArray:Array = event.result as Array;
			Assert.assertNotNull(cArray);
			Assert.assertTrue((cArray.length > 0 && cArray.length < 21) );
			Assert.assertTrue( cArray[0] is MicroBlogComment );
		}
		
		public static function assertComment(event:MicroBlogEvent, params:Object=null):void
		{
			Assert.assertTrue( event.result is MicroBlogComment );
		}
		
		public static function assertStatusArray(event:MicroBlogEvent, params:Object=null):void
		{
			var statusArray:Array = event.result as Array;
			Assert.assertNotNull(statusArray);
			Assert.assertTrue((statusArray.length > 0 && statusArray.length < 21) );
			Assert.assertTrue( statusArray[0] is MicroBlogStatus );
		}
		public static function assertStatus(event:MicroBlogEvent, params:Object=null):void
		{
			var status:MicroBlogStatus = event.result as MicroBlogStatus;
			Assert.assertNotNull(status);
			
		}
		public static function assertCountArray(event:MicroBlogEvent, params:Object=null):void
		{
			var countArray:Array = event.result as Array;
			Assert.assertNotNull(countArray);
			Assert.assertTrue(countArray.length > 0);
			Assert.assertTrue(countArray[0] is MicroBlogCount);
		}
		
		public static function assertUser(event:MicroBlogEvent, param:Object=null):void
		{
			var user:MicroBlogUser = event.result as MicroBlogUser;
			Assert.assertNotNull(user);
		}
		public static function assertUserArray(event:MicroBlogEvent, param:Object=null):void
		{
			var userArrayr:Array = event.result as Array;
			Assert.assertNotNull(userArrayr);
			Assert.assertTrue(userArrayr.length > 0);
			Assert.assertTrue(userArrayr[0] is MicroBlogUser);
		}
		public static function assertMessage(event:MicroBlogEvent, param:Object=null):void
		{
			var msg:MicroBlogDirectMessage = event.result as MicroBlogDirectMessage;
			Assert.assertNotNull(msg);
		}
		public static function assertMessageArray(event:MicroBlogEvent, param:Object=null):void
		{
			var msgArrayr:Array = event.result as Array;
			Assert.assertNotNull(msgArrayr);
			Assert.assertTrue(msgArrayr.length > 0);
			Assert.assertTrue(msgArrayr[0] is MicroBlogDirectMessage);
		}
		
		public static function assertRelationship(event:MicroBlogEvent, param:Object=null):void
		{
			var r:MicroBlogUsersRelationship = event.result as MicroBlogUsersRelationship;
			Assert.assertNotNull(r);
			var target:MicroBlogRelationshipDescriptor = r.target;
			var source:MicroBlogRelationshipDescriptor = r.source;
			Assert.assertNotNull(target);
			Assert.assertNotNull(source);
		}
		
		public static function assertIDList(event:MicroBlogEvent, param:Object=null):void
		{
			var idArray:Array = event.result as Array;
			Assert.assertNotNull(idArray);
			Assert.assertTrue(idArray.length > 0);
			Assert.assertTrue(idArray[0] is uint);
		}
		
		public static function assertRateLimits(event:MicroBlogEvent, param:Object=null):void
		{
			var limits:MicroBlogRateLimit = event.result as MicroBlogRateLimit;
			Assert.assertNotNull(limits);
		}
		
		public static function assertProvinces(event:MicroBlogEvent, param:Object=null):void
		{
			Assert.assertTrue(event.result is XML);
		}
	
	}
}